<template>
  <nav-header :title="title+'-'+dictType+'(' + data.pageTotal + ')'">
			<my-page ref="mypage" v-model="dataList" @load-data="loadData">
				<template slot="content">
					<view v-for="(item,index) in dataList" :key="index" class="py-4 border-b-ee flex items-center"
						@click="$util.myNavigateTo('/pages_home/lianmeng/company_detail?id=' + item.id)">
						<image :src="$util.formatImageIdUrl(item.logo)" class="w-16 h-16"></image>
						<view class="flex-1 pl-4">
							<view class="text-black-32 font-bold" v-text="item.name"></view>
							<view  class="mt-1_5 text-gray-66 text-sm zx-multi-ellipsis--2" v-text="item.tagList.replace(/\;/g, '')"></view>
						</view>
					</view>
				</template>
			</my-page>
  </nav-header>
</template>

<script>
import {mapState} from 'vuex'
	import MyPage from '@/components/my_page.vue'
	import * as unionApi from '@/interface/junchuang/union.js'
  import * as systemApi from '@/interface/common/system.js'
  import NavHeader from '@/components/nav_header.vue'

  export default {
    props: {
      codeType: {
        type: String,
        default: ''
      },
      dictType: {
        type: String,
        default: ''
      },
    },
		components: {
      NavHeader,MyPage
		},
		data() {
			return {
        title:'服务',
				unionObj: {
					title: '',
					image: '',
					summary: '',
					content: ''
				},
				dataList: [],
				data: {pageTotal: 0,type:''},
				bgUrl: this.$config.server_pic_url + 'bg_lianmeng.png',
        dictType: '',
			}
		},
    computed: {
      ...mapState({
        system: state => state.system
      })
    },
		mounted() {

		},
    onReady() {
      const v = this
      let dictType = ''
      switch (v.codeType) {
        case 'qiye': v.title = '企业服务'; break;
        case 'chanye': v.title = '产业服务'; break;
        case 'shenghuo': v.title = '生活服务'; break;
        case 'jinrong': v.title = '金融服务'; break;
      }
      systemApi.getDictList(dictType).then(({ data }) => {
        data.forEach(item=>{
          v.tabList.push({
            name: item.dictLabel,
            val: item.dictValue
          })
        })
      })
    },
		methods: {
			loadData(page, success, error){
				Object.assign(this.data, page, {
					type: this.codeType,
          businessType: this.dictType
				})
				unionApi.getCompanyPageList(this.data).then(res=>{
					this.data.pageTotal = res.data.total || 0
          console.log("this.data.",res)
					success(res)
				}).catch(error)
			},
      reloadData() {
        this.$refs['mypage'].dataReload()
      }
		}
	}
</script>

<style>
page{
  background-color: #f7f7f7;
}

.masonry {
  column-count: 2;
  column-gap: 0.5rem;
}

.item {
  break-inside: avoid;
  box-sizing: border-box;
}
</style>
